import request from '@/utils/request'
import storage from '@/utils/storage';
// api地址
const api = {
	info: '/user/center',
	bindZfb: '/user/bindZfb',
	getWithdrawInfo: '/withdrawal/config',
	withdrawal: '/withdrawal/doWithdrawal',
	withdrawLog: '/withdrawal/lists',
	accountLog: '/accountLog/lists',
	commissionLog: '/user/commissionLog',
	getEstimatedAmount: 'user/getEstimatedAmount',
	getLevelList: '/user/getLevelList',
	upLevel: '/user/upLevel',
	teamList: '/user/teamList'
}


export function getUserInfo(data, option) {
	return request.post(api.info, data, option).then(res => {
		storage.set('userInfo', res.data);
		if (storage.get('game_openid') && !res.data.auth.game_openid) {
			request.get("login/bindGame", {
				bwc_openid: storage.get("userInfo").auth.openid, //霸王餐的openid
				game_openid: storage.get('game_openid'), //游戏的openid
			})
		}
		return res
	})
}


export function bindZfb(data, option) {
	return request.post(api.bindZfb, data, option)
}

export function getWithdrawInfo(data, option) {
	return request.post(api.getWithdrawInfo, data, option)
}

export function withdrawal(data, option) {
	return request.post(api.withdrawal, data, option)
}

export function getWithdrawLog(data, option) {
	return request.get(api.withdrawLog, data, option)
}

export function getAccountLog(data, option) {
	return request.get(api.accountLog, data, option)
}

export function getCommissionLog(data, option) {
	return request.get(api.commissionLog, data, option)
}


export function getEstimatedAmount(data, option) {
	return request.get(api.getEstimatedAmount, data, option)
}

export function getLevelList(data, option) {
	return request.get(api.getLevelList, data, option)
}

export function teamList(data, option) {
	return request.get(api.teamList, data, option)
}


export function upLevel(data, option) {
	return request.post(api.upLevel, data, option)
}